﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HtmlAgilityPack;
using Kooboo.HtmlFunc.Function;
using Kooboo.HtmlFunc.Providers;

namespace Kooboo.HtmlFunc.Analysis.Visitors
{
    public class LayoutVisitor : VisitorBase
    {
        public LayoutVisitor(VisitorContext context)
            : base(context, FuncType.Layout)
        {
        }

        public override void VisitDocument(HtmlDocument document)
        {
            var layout = Provider.Factory.GetProvider<ILayout>();
            layout.Name = System.IO.Path.GetFileNameWithoutExtension(this.Context.FileName);
            layout.Document = document;
            this.Context.Result.Layout = layout;
        }
    }
}
